package user

import (
	"context"
	"fmt"
	"github.com/robfig/cron/v3"
	"srv/config"
	"srv/internal/model/dao"
	__ "srv/proto"
	"time"
)

// 实现方法
func (s *UserService) GvaExamTitleFind(ctx context.Context, req *__.GvaExamTitleFindRequest) (resp *__.GvaExamTitleFindResponse, err error) {
	var title dao.GvaExamTitle
	config.DB.Where("name like ?", "%"+req.Name+"%").Find(&title)
	config.Rdb.Set("title", title.Name, time.Minute*5)
	c := cron.New()
	c.Start()
	c.AddFunc("10/* * * * *", func() { fmt.Println("十分钟后开始考试") })
	c.Stop()
	return &__.GvaExamTitleFindResponse{
		Name:          title.Name,
		ExamTitleType: int64(title.ExamTitleType),
		TitleOrigin:   int64(title.TitleOrigin),
		TitleNum:      int64(title.TitleNum),
		CreateName:    title.CreateName,
		Open:          int64(title.Open),
	}, nil
}
